package hn.cch.framework.database;

import org.junit.Test;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;

public class H2Demo {

    @Test
    public void test() throws Exception {

    }

    @Test
    public void testEmbedded() throws Exception {
        Class.forName("org.h2.Driver");
        Connection connection = DriverManager.getConnection("jdbc:h2:./h2", "sa", ""); // h2.mv.db
        Statement statement = connection.createStatement();
        System.out.println(connection);
        System.out.println(statement);
    }

    @Test
    public void testMemory() throws Exception {
        Class.forName("org.h2.Driver");
        Connection connection = DriverManager.getConnection("jdbc:h2:tcp://localhost/mem:h2", "sa", "");
        Statement statement = connection.createStatement();
        System.out.println(connection);
        System.out.println(statement);
    }

    @Test
    public void testServer() throws Exception {
        Class.forName("org.h2.Driver");
        Connection connection = DriverManager.getConnection("jdbc:h2:tcp://localhost/~/h2", "sa", "");
        Statement statement = connection.createStatement();
        System.out.println(connection);
        System.out.println(statement);
    }

}
